using GMT
compass(width=2.5, fancy=true, labels=",,,N", show=true)Precompiling packages... 55708.7 ms ✓ GMT 1 dependency successfully precompiled in 57 seconds. 80 already precompiled.

Draw a map directional rose or magnetic compass on the map.
Convenience function that wraps basemap to draw directional (-Td) or magnetic (-Tm) compass roses. The mode is auto-selected: if dec (magnetic declination) is provided, a magnetic compass is drawn; otherwise a directional rose is drawn.
Can be called standalone (creates its own plot) or as an overlay (compass!) on an existing plot. When called standalone without region/proj, a default canvas sized to fit the rose is created automatically using paper coordinates.
anchor : – anchor=(x,y) | anchor=refpoint
Reference point on the map for the rose. When called standalone without region/proj, this is interpreted as paper coordinates (cm). In overlay mode or with explicit region/proj, the coordinate system is determined by the map, inside, outside, norm, or paper modifiers.
width : – width=val
Width of the rose in plot coordinates (cm). This also controls the auto-generated canvas size when no region/proj is given.
fancy : – fancy=true | fancy=level
Draw a “fancy” rose. Level 1 (or true) draws the two principal E-W, N-S orientations. Level 2 adds the two intermediate NW-SE and NE-SW orientations. Level 3 adds the eight minor orientations.
labels or label : – labels=“W,E,S,N”
Comma-separated labels for the cardinal points. Skip a label by leaving it blank (e.g., ",,,N"). Use labels=true to get the default W,E,S,N labels.
justify : – justify=code
2-char justification code for the anchor point (e.g., :CM for center-middle). See text.
offset : – offset=(dx,dy)
Offset from the anchor point.
map, inside, outside, norm, paper :
Coordinate system for the anchor point. Use map=true for map coordinates, inside=code or outside=code for justification-based placement, norm=true for normalized (0-1) coordinates, or paper=true for plot coordinates.
All directional options above, plus:
dec : – dec=val
Magnetic declination in degrees. The presence of this option switches the function to magnetic compass mode (-Tm).
annot : – annot=(a1,a2,a3,a4,a5,a6)
Six annotation/tick intervals: the first three for geographic directions (annotation, tick, minor tick) and the last three for magnetic directions. Default is 30/5/1 for both.
rose_primary : – rose_primary=pen | rose_primary=(width, color)
Pen for the outer (primary) circle of the compass.
rose_secondary : – rose_secondary=pen | rose_secondary=(width, color)
Pen for the inner (secondary) circle of the compass.
All other keyword arguments are passed to basemap. Common ones include:
Note: when compass is called without an explicit frame, it defaults to frame=:none so that only the compass rose is drawn (no axes).
A simple directional rose — no region or proj needed. The canvas is auto-sized to fit the rose.
Plain, fancy level 1, and fancy level 3, plotted using overlay mode with shifts.
using GMT
basemap(region=(-5,5,-5,5), proj=:merc, figscale=0.4, frame=:none,
rose=(map=true, anchor=(0,0), justify=:CM, width=2.5))
compass!(width=2.5, anchor=(0,0), justify=:CM, fancy=true, labels=",,,N", xshift=3)
compass!(width=2.5, anchor=(0,0), justify=:CM, fancy=3, labels=true,
region=(-7,7,-5,5), xshift=3.5, show=true)
A magnetic compass with declination of -14.5 degrees and custom annotation intervals.
This function has multiple methods:
compass(first::Bool, d::Dict{Symbol, Any}) - compass.jl:64compass(; first, kw...) - compass.jl:60